﻿using System;

using enyo;

namespace com.RexToy
{
    public class LengView : ConverterView
    {
        private object[] components = new object[]{ 
            new {kind= ControlKind.BasicScroller, 
                components=new object[] {
                    new {kind=ControlKind.RowGroup, 
                        components= new object[]{
				            new {name= "m", richContent= false, kind = ControlKind.Input, onblur="blur",
                                    components=new object[]{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Meter")}
                                    }
                            },
                            new {name= "km", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components= new object[]{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Kilometer")}
				                    }
                            },
				            new {name= "sm", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Sea Mile")}
				                   }
				            },
                            new {name= "mi", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Mile")}
				                   }
				            },
                            new {name= "in", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Inch")}
				                   }
				            },
                            new {name= "ft", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Feet")}
				                   }
				            },
                            new {name= "li", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Li(China)")}
				                   }
				            },
                            new {name= "zh", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Zhang(China)")}
				                   }
				            },
                            new {name= "ch", richContent= false, kind= ControlKind.Input, onblur="blur", 
                                    components=new object []{
					                    new {className= "hint", content= enyo.g11nGlobal._L("Chi(China)")}
				                   }
				            }
			            }                    
		            }      
                }
            }
        };

        public override void Create()
        {
            this.Inherited(Arguments.Value);

            this.units = new string[] { "m", "km", "sm", "mi", "in", "ft", "li", "zh", "ch" };
            this.baseUnit = "m";

            this.fomular = new object();
            this.fomular["m->m"] = "m";
            this.fomular["m->km"] = "m/1000";
            this.fomular["km->m"] = "km*1000";
            this.fomular["m->sm"] = "m/1852";
            this.fomular["sm->m"] = "sm*1852";
            this.fomular["m->mi"] = "m/1609.344";
            this.fomular["mi->m"] = "mi*1609.344";
            this.fomular["m->in"] = "m*39.3701";
            this.fomular["in->m"] = "in/39.3701";
            this.fomular["m->ft"] = "m*3.2808";
            this.fomular["ft->m"] = "ft/3.2808";
            this.fomular["m->li"] = "m/500";
            this.fomular["li->m"] = "li*500";
            this.fomular["m->zh"] = "m*0.3";
            this.fomular["zh->m"] = "zh/0.3";
            this.fomular["m->ch"] = "m*3";
            this.fomular["ch->m"] = "ch/3";
        }
    }
}
